package fc.testmain;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson.JSON;
import fc.FcHttpCon;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

public class T100CUST_CREATE {

//    public static void main(String[] args) {
//        DateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
//        String timestamp = format.format(new Date());
//        DateFormat formataa = new SimpleDateFormat("yyyy-MM-dd");
//        String createdate = formataa.format(new Date());
//
//        // 修复了字符串中的反斜杠转义问题
//        String json_param = "{\"key\": \"a5e7f741701e726aefeaaa58199a724f\",\"type\": \"sync\",\"host\": {\"prod\": \"OAPI\",\"ip\": \"10.10.10.1\",\"lang\": \"zh_CN\",\"timestamp\": \"20250620123401169\",\"acct\": \"tiptop\"},\"service\": {\"prod\": \"T100\",\"name\": \"supplier_crt\",\"ip\": \"10.10.10.75\",\"id\": \"topprod\"},\"datakey\": {\"EntId\": \"2\",\"CompanyId\": \"ZH00\",\"supplier_no\": \"S01223\"},\"payload\": {\"std_data\": {\"parameter\": {\"enterprise_no\": \"2\", \"site_no\": \"ZH00\",\"is_digiwin_product\": \"Y\",\"supplier_detail\": [{\"tp\": \"10\",\"supplier_no\": \"S01223\",\"supplier_full_name\": \"东莞市瑞施博格导轨制造有限公司\",\"supplier_shortname\": \"东莞市瑞施博格导轨制造有限公司\",\"trans_object_type\": \"1\",\"if_temp\": \"2\",\"legal_type\": \"1\",\"belong_legal\": \"S01223\",\"belong_group_no\": \"\",\"uniform_number\": \"91441900MA4W0NN37J\",\"country_no\": \"CN\",\"industry_id\": \"\",\"monthly_settlement_day\": \"1\",\"payment_day\": \"1\",\"receivable_day\": \"1\",\"purchaser_no\": \"MW25050723175\",\"responsibility_department_no\": \"800904\",\"create_employee_no\": \"MW25050723175\",\"currency_no\": \"CNY\",\"tax_no\": \"T08\", \"payment_condition_no\": \"A08\",\"trade_condition_no\": \"KD\",\"account_type\": \"AP01\",\"get_prc_way\": \"001\",\"invoice_type\": \"T1\",\"create_date\": \"2025-06-20\",\"trans_object_relation_detail\": [{\"trade_type\": \"1\",\"is_main\": \"Y\",\"trans_object_no\": \"S01223\"}],\"contact_address_detail\": [{\"brief_no\": \"1\",\"address_type\": \"1\",\"is_main_contact_address\": \"Y\",\"country_code\": \"CN\",\"address\": \"东莞市厚街镇沙塘社区沙隆路德朗实业创新园D栋1楼102号\",\"expiration_date\": \"9999-01-01\"}],\"communication_detail\": [{\"communication_type\": \"2\",\"communication_content\": \"13316600026\",\"is_main_communication_method\": \"Y\",\"expiration_date\": \"9999-01-01\"}],\"bank_info\": [{\"bank_code\": \"402602009015\",\"bank_account\": \"090150190010016509\",\"main_receive_bank_account\": \"Y\",\"main_payment_bank_account\": \"Y\",\"owner_name\": \"东莞市瑞施博格导轨制造有限公司\"}],\"allow_payment_condition\": [{\"trade_condition_no\": \"A08\", \"is_main\": \"N\"}]}]}}}}";
//
//        System.out.println(json_param);
//        //调用 ECOLOGY 系统接口
//        String data = HttpRequest.post(FcHttpCon.ZH_YFSY_XQ).body(json_param).execute().body();
//
//        System.out.println(data);
//        String result = "ERROR";
//        System.out.println("----------------");
//
//        try {
//            Object succesResponse = JSON.parse(data);
//            Map map = (Map) succesResponse;
//            Map map1 = (Map) map.get("payload");
//            Map map2 = (Map) map1.get("std_data");
//            Map map3 = (Map) map2.get("execution");
//            if ("0".equals(map3.get("code"))) {
//                result = "SUCCESS";
//            } else {
//                Map map4 = (Map) map2.get("parameter");
//
//                System.out.println(map4);
//
//                JSONArray jsonArray = new JSONArray(map4.get("supplier_no"));
//                System.out.println(jsonArray);
//                for (int i = 0; i < jsonArray.size(); i++) {
//                    JSONObject infog = new JSONObject((Map<String, Object>) jsonArray.get(i));
//                    Map mapg = (Map) infog;
//                    result = mapg.get("execute_description").toString();//1
//                }
//            }
//
//            // System.out.println(map1);
//        } catch (Exception e) {
//            System.out.println("T100CUST_CREATE接口报错了！！！！！！！！");
//            e.printStackTrace();
//        }
//        System.out.println("result:" + result);
//    }
}